home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / pctecap.arc / SETKEY.ASM < prev    next >
Assembly Source File  |  1986-03-15  |  3KB  |  116 lines

  1.  
  2. ;----------------------------------------------------------------------
  3. ;name:    setkey.asm    (setkey.com)
  4. ;desc:    set typematic speed/delay on ibm pc at
  5. ;by:    kevin m. crenshaw
  6. ;date:    12/27/84
  7. ;
  8. ;use:    setkey [a][n]
  9. ;        a = typematic speed
  10. ;            (letter a to z or symbol [ to `)
  11. ;        n = delay value
  12. ;            (digit 1 to 4)
  13. ;
  14. ;note:    follow these steps to create setkey.com:
  15. ;        masm setkey;
  16. ;        link setkey;
  17. ;        exe2bin setkey setkey.com
  18. ;        del setkey.exe
  19. ;----------------------------------------------------------------------
  20.  
  21. cseg    segment
  22. assume    cs:cseg,ds:cseg
  23.  
  24. org    100h
  25.  
  26. ;------ get typematic rate:  a to z, [, \, ], ^, _, or `
  27.  
  28. start:    mov    si,81h            ;point to command line
  29.     xor    bx,bx            ;set default
  30. letter:    lodsb                ;get first non-space char
  31.     cmp    al," "
  32.     je    letter
  33.     jb    send            ;end of line, use default
  34.     dec    al
  35.     and    al,0dfh            ;upper case
  36.     sub    al,"@"            ;valid letter or symbol?
  37.     jnb    lettr1            ;  maybe
  38.     dec    si            ;  no, might be a digit
  39.     jmp    short digit
  40. lettr1:    cmp    al,31            ;valid letter or symbol?
  41.     ja    error2            ;  no, error
  42.     xchg    al,bl            ;  yes, save as typematic rate
  43.  
  44. ;------ get delay value:  1 to 4
  45.  
  46. digit:    lodsb                ;get next non-space char
  47.     cmp    al," "
  48.     je    digit
  49.     jb    send            ;end of line, use what we have
  50.     sub    al,"1"            ;valid digit?
  51.     jb    error2            ;  no, error
  52.     cmp    al,3            ;valid digit?
  53.     ja    error2            ;  no, error
  54.     mov    cl,5            ;  yes, save as delay value
  55.     shl    al,cl
  56.     or    bl,al
  57.  
  58. ;------ send values to keyboard
  59.  
  60. send:    mov    al,0f3h            ;set typematic/delay
  61.     call    xmit            ;command accepted?
  62.     jcxz    error1            ;  no, error
  63.     xchg    al,bl            ;send typematic/delay values
  64.     call    xmit            ;values accepted?
  65.     jcxz    error1            ;  no, error
  66.     int    20h            ;return to dos
  67.  
  68. ;------ bad input
  69.  
  70. error1:    mov    dx,offset error1$    ;hardware error
  71.     jmp    short error
  72. error2:    mov    dx,offset error2$    ;bad input error
  73. error:    mov    ah,9            ;print message
  74.     int    21h
  75.     int    20h
  76.  
  77. error1$    db    "Hardware error",13,10,"$"
  78. error2$    db    "Valid parameters are  A-Z  followed by  1-4",13,10,"$"
  79.  
  80. ;xmit - send data to keyboard 
  81. ;in:    al    - data to send
  82. ;out:    ax    - destroyed
  83. ;    cx    - zero if error, nonzero otherwise
  84. ;
  85. xmit    proc    near
  86.     cli                ;interrupts off
  87.     xchg    al,ah            ;save command
  88.     xor    cx,cx
  89. xmtwt1:    in    al,64h
  90.     test    al,2            ;is data waiting for controller?
  91.     loopnz    xmtwt1            ;  yes, wait
  92.     jcxz    xmtret            ;  error, controller not reading data
  93.     xchg    al,ah            ;get command back
  94.     out    60h,al            ;send to keyboard
  95.     xor    cx,cx
  96. xmtwt2:    in    al,64h
  97.     test    al,2            ;has controller read data yet?
  98.     loopnz    xmtwt2            ;  no, wait
  99.     jcxz    xmtret            ;  error, controller not reading data
  100.     xor    cx,cx
  101. xmtwt3:    in    al,64h
  102.     test    al,1            ;did keyboard send ACK yet?
  103.     loopz    xmtwt3            ;  no, wait for it
  104.     jcxz    xmtret            ;  error, no response
  105.     in    al,60h            ;get response
  106.     cmp    al,0fah            ;was it ACK?
  107.     je    xmtret            ;  yes
  108.     xor    cx,cx            ;  no, error
  109. xmtret:    sti                ;interrupts back on
  110.     ret
  111. xmit    endp
  112.  
  113. cseg    ends
  114.  
  115.     end    start
  116.